Skip to content

Conversation

@jqnatividad
Copy link

In my qsv project, dynfmt using the SimpleCurlyFormat was working correctly in debug mode, but not in release mode!

Out of desperation, I tried modernizing dynfmt by just going to 2021 edition, bumping dependencies, and applying the clippy::swap_ptr_to_ref suggestion and it worked!

As to why, I dunno, but I'm contributing this back just in case other folks have a similar problem.

warning: call to `core::mem::swap` with a parameter derived from a raw pointer
   --> src/formatter.rs:145:13
    |
145 |             mem::swap(self, &mut *placeholder.as_mut_ptr());
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use ptr::swap: `core::ptr::swap(self, placeholder.as_mut_ptr())`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#swap_ptr_to_ref
    = note: `#[warn(clippy::swap_ptr_to_ref)]` on by default
@pkgw
Copy link

pkgw commented Dec 14, 2023

Thanks @jqnatividad, I just ran into exactly this problem myself!

For anyone else running into this, if you are comfortable relying on someone else's GitHub branch, you can steal the fix from the qsv PR linked above by adding the following to your Cargo.toml:

# https://github.com/jan-auer/dynfmt/pull/9
[patch.crates-io]
dynfmt = { git = "https://github.com/jqnatividad/dynfmt", branch = "2021-clippy_ptr_as_ptr-bumpdeps" }

pkgw added a commit to pkgw/cranko that referenced this pull request Dec 14, 2023
See: jan-auer/dynfmt#9

And: https://github.com/jqnatividad/qsv/pull/1467/files

This should go away when a new dynfmt release comes out, or at least
migrate to a scheme where we're not relying on someone else's repo and
branch. But this should be OK for now.
@jqnatividad
Copy link
Author

A renamed fork - dynfmt2, is now available.
https://crates.io/crates/dynfmt2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants